.cm-editor {
  height: 100%;
  font-family: monospace;
  border-radius: 4px;
  overflow: hidden;
}

.cm-scroller {
  overflow: auto;
}

.cm-content {
  padding: 10px;
}

.cm-line {
  padding: 0 4px;
  line-height: 1.6;
}

.cm-activeLineGutter {
  background-color: rgba(0, 0, 0, 0.1);
}

.cm-gutters {
  border-right: 1px solid var(--color-border);
  background-color: var(--color-code-background);
  color: var(--color-text-3);
}

.cm-gutterElement {
  padding: 0 3px 0 5px;
}

/* Dark theme specific styles */
.dark-theme .cm-editor {
  background-color: #282c34;
  color: #abb2bf;
}

.dark-theme .cm-gutters {
  background-color: #21252b;
  color: #636d83;
}

.dark-theme .cm-activeLineGutter {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 自动补全样式 */
.cm-tooltip {
  border: 1px solid var(--color-border);
  background-color: var(--color-background);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.cm-tooltip.cm-tooltip-autocomplete {
  min-width: 200px;
}

.cm-tooltip-autocomplete ul {
  font-family: monospace;
  padding: 0;
  margin: 0;
}

.cm-tooltip-autocomplete li {
  padding: 4px 8px;
  cursor: pointer;
}

.cm-tooltip-autocomplete li:hover {
  background-color: var(--color-hover);
}

.cm-tooltip-autocomplete .cm-completionLabel {
  color: var(--color-text);
}

.cm-tooltip-autocomplete .cm-completionDetail {
  color: var(--color-text-3);
  font-size: 0.9em;
  margin-left: 8px;
}

.cm-tooltip-autocomplete .cm-completionIcon {
  display: none;
}

.cm-tooltip-autocomplete .cm-completionMatchedText {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: bold;
}

.dark-theme .cm-tooltip {
  background-color: #282c34;
  border-color: #3e4451;
}

.dark-theme .cm-tooltip-autocomplete .cm-completionLabel {
  color: #abb2bf;
}

.dark-theme .cm-tooltip-autocomplete .cm-completionDetail {
  color: #636d83;
}

.dark-theme .cm-tooltip-autocomplete .cm-completionMatchedText {
  color: #61afef;
}

.dark-theme .cm-tooltip-autocomplete li:hover {
  background-color: #3e4451;
}

/* 查找和替换面板样式 */
.cm-search {
  max-width: 300px;
  display: flex;
  flex-direction: column;
  padding: 8px;
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 200;
}

.cm-search input {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  background-color: var(--color-background);
  color: var(--color-text);
}

.cm-search button {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 8px;
  margin: 2px;
  background-color: var(--color-background);
  color: var(--color-text);
  cursor: pointer;
}

.cm-search button:hover {
  background-color: var(--color-hover);
}

.cm-search label {
  display: flex;
  align-items: center;
  margin: 2px 0;
  font-size: 0.9em;
  color: var(--color-text);
}

.cm-search input[type="checkbox"] {
  margin-right: 4px;
}

.cm-searchMatch {
  background-color: rgba(250, 166, 26, 0.2);
}

.cm-searchMatch-selected {
  background-color: rgba(250, 166, 26, 0.5);
}

.dark-theme .cm-search {
  background-color: #282c34;
  border-color: #3e4451;
}

.dark-theme .cm-search input {
  background-color: #21252b;
  border-color: #3e4451;
  color: #abb2bf;
}

.dark-theme .cm-search button {
  background-color: #21252b;
  border-color: #3e4451;
  color: #abb2bf;
}

.dark-theme .cm-search button:hover {
  background-color: #3e4451;
}

.dark-theme .cm-search label {
  color: #abb2bf;
}

.dark-theme .cm-searchMatch {
  background-color: rgba(229, 192, 123, 0.3);
}

.dark-theme .cm-searchMatch-selected {
  background-color: rgba(229, 192, 123, 0.6);
}

/* 中文搜索面板样式覆盖 */
.cm-panel.cm-search {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.cm-panel.cm-search input[name="search"] {
  width: 10em;
}

.cm-panel.cm-search input[name="replace"] {
  width: 10em;
}

.cm-panel.cm-search button[name="find"] {
  content: '查找';
}

.cm-panel.cm-search button[name="next"] {
  content: '下一个';
}

.cm-panel.cm-search button[name="prev"] {
  content: '上一个';
}

.cm-panel.cm-search button[name="replace"] {
  content: '替换';
}

.cm-panel.cm-search button[name="replaceAll"] {
  content: '全部替换';
}

.cm-panel.cm-search label[for="case"] {
  content: '区分大小写';
}

.cm-panel.cm-search label[for="regexp"] {
  content: '正则表达式';
}

.cm-panel.cm-search label[for="word"] {
  content: '全词匹配';
}

/* 修改按钮文本 */
.cm-panel.cm-search button[name="find"]::before {
  content: '查找';
}

.cm-panel.cm-search button[name="next"]::before {
  content: '下一个';
}

.cm-panel.cm-search button[name="prev"]::before {
  content: '上一个';
}

.cm-panel.cm-search button[name="replace"]::before {
  content: '替换';
}

.cm-panel.cm-search button[name="replaceAll"]::before {
  content: '全部替换';
}

/* 修改标签文本 */
.cm-panel.cm-search label[for="case"]::after {
  content: '区分大小写';
}

.cm-panel.cm-search label[for="regexp"]::after {
  content: '正则表达式';
}

.cm-panel.cm-search label[for="word"]::after {
  content: '全词匹配';
}
